import {ElMessage} from "element-plus";

const key = "USER_INFO"


//存储数据
export function setUserInfo(userInfo: any) {
    localStorage.setItem(key, JSON.stringify(userInfo))
}

//获取数据
export function getUserInfo() {
    const userInfo = localStorage.getItem(key)
    return userInfo ? JSON.parse(userInfo) : {}
}

//删除数据
export function removeUserInfo() {
    if (localStorage.getItem(key)) {
        localStorage.removeItem(key)
    } else {
        ElMessage.error('没有用户信息,操作失败!')
    }
}